export function calcTimeAgo(time) {
	var minute = 1000 * 60;
	var hour = minute * 60;
	var day = hour * 24;
	var week = day * 7;
	var halfamonth = day * 15;
	var month = day * 30;
	var now = new Date().getTime();
	var dateTime = new Date(time);
	var diff = now - dateTime;
	if (diff < 0) {
		return;
	}
	var minV = diff / minute;
	var hourV = diff / hour;
	var dayV = diff / day;
	var weekV = diff / week;
	var monthV = diff / month;
	var result = "";
	if (monthV >= 1 && monthV <= 3) {
		result = result + parseInt(monthV) + "月前"
	} else if (weekV >= 1 && weekV <= 3) {
		result = result + parseInt(weekV) + "周前"
	} else if (dayV >= 1 && dayV <= 6) {
		result = result + parseInt(dayV) + "天前"
	} else if (hourV >= 1 && hourV <= 23) {
		result = result + parseInt(hourV) + "小时前"
	} else if (minV >= 1 && minV <= 59) {
		result = result + parseInt(minV) + "分钟前"
	} else if (diff >= 0 && diff <= minute) {
		result = "刚刚"
	} else {
		var datetime = new Date();
		datetime.setTime(dateTime);
		var Nyear = datetime.getFullYear();
		var Nmonth = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
		var Ndate = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
		var Nhour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours();
		var Nminute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
		var Nsecond = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
		result = Nyear + "-" + Nmonth + "-" + Ndate
	}
	return result;
}
